package xidian.vlab.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import xidian.vlab.domin.Log;
import xidian.vlab.dto.ListDTO;
import xidian.vlab.dto.QueryDTO;
import xidian.vlab.dto.ResJsonDTO;
import xidian.vlab.repository.LogRepository;
import xidian.vlab.service.LogService;
import xidian.vlab.utils.ResUtil;

import java.util.List;

@Service("LogService")
public class LogServiceImpl implements LogService {
    @Autowired
    private LogRepository logRepo;

    @Override
    public ResJsonDTO getLog(QueryDTO query) {
        ListDTO list = new ListDTO();
        List<Log> logs = logRepo.findAll();
        list.setLogList(logs);
        list.setTotal(logs.size());
        System.out.println("管理员["+query.getAid()+"]获取日志列表成功");
        return ResUtil.OK(list);
    }
    @Override
    public void addLog(Log log) {
        logRepo.save(log);
        System.out.println(log);
    }
}
